This chapter is not necessarily a tutorial. If you want to learn how to edit, save, and run scripts, you may not find the information here. Instead, refer to other tools and sources of information listed in "Tools and Reference Material" for more information.
The topics in this chapter are:
You can find numerous resources and pointers to information on the world wide web at:
http://msdn.microsoft.com/scripting/
http://www.microsoft.com/com/resources/oleview.asp
Other editing and debugging tools may be available from third-party vendors.
To use OLE/COM Object Viewer, launch it and you will see something similar to Figure 3.1. Use the View menu to put it into Expert Mode, clickon the plus sign "+" next to Type Libraries in the left window pane, then click on the Metrowerks CodeWarrior IDE entry.
interface ICodeWarriorProject;
interface IFileSpec;
interface ICodeWarriorDesignCollection;
interface ICodeWarriorDesign;
interface ICodeWarriorTargetCollection;
interface ICodeWarriorTarget;
interface ICodeWarriorSymbolContainer;
interface ICodeWarriorClassCollection;
interface ICodeWarriorClass;
interface ICodeWarriorSymbol;
interface ICodeWarriorSourceContext;
interface ICodeWarriorBaseClassCollection;
interface ICodeWarriorBaseClassInfo;
interface ICodeWarriorDataMemberCollection;
interface ICodeWarriorDataMember;
interface ICodeWarriorMethodCollection;
interface ICodeWarriorMethod;
interface ICodeWarriorProjectFileCollection;
interface ICodeWarriorProjectFile;
interface ICodeWarriorVCSState;
interface ICodeWarriorTargetFileCollection;
interface ICodeWarriorTargetFile;
interface ICodeWarriorAccessPaths;
interface ICodeWarriorAccessPathCollection;
interface ICodeWarriorAccessPath;
interface ICodeWarriorUserTree;
interface ICodeWarriorUserTreeCollection;
interface ICodeWarriorSubTargetCollection;
interface ICodeWarriorSubTarget;
interface IFileSpecCollection;
interface IBSTRCollection;
interface IStream;
interface ISequentialStream;
interface ICodeWarriorBuildMessages;
interface ICodeWarriorMessageCollection;
interface ICodeWarriorMessage;
interface ICodeWarriorTargetOutput;
interface ICodeWarriorApp;
interface ICodeWarriorProjectCollection;
interface ICodeWarriorCreatableItemCollection;
interface ICodeWarriorCreatableItem;
interface ICodeWarriorDocumentCollection;
interface ICodeWarriorDocument;
interface ICodeWarriorProjectDocument;
interface ICodeWarriorVersionControl;
interface ICodeWarriorTextDocument;
interface ICodeWarriorTextEngine;
interface ICodeWarriorComponent;
interface ICodeWarriorComponentPropertyCollection;
interface ICodeWarriorComponentProperty;
interface ICodeWarriorComponentEventSetCollection;
interface ICodeWarriorComponentEventSet;
interface ICodeWarriorComponentEventCollection;
interface ICodeWarriorComponentEvent;
interface ICodeWarriorSymbolCollection;
interface ICodeWarriorComponentCollection;
interface ICodeWarriorAppEvents;
interface ICodeWarriorProjectEvents;
interface ICodeWarriorDesignEvents;
interface ICodeWarriorDesignAttachment;
interface ICodeWarriorCreateProjectItem;
interface ICodeWarriorCreateFileItem;
interface ICodeWarriorCreateObjectItem;
interface ICodeWarriorVCSFileStateListener;
interface ICodeWarriorProjectAssociation;
interface ICodeWarriorErrorInfo;
This section will show you how to get a jump on starting to write your own scripts.
The topics in this section are:
Note that one of the first lines of your script should be something like:
set codewarrior = CreateObject("CodeWarrior.CodeWarriorApp")
set project = codewarrior.OpenProject(projectname, true, 2, 0 )
To do this for the OpenProject
method, you would first launch OLE/COM Object Viewer. Then use the View menu to put it into Expert Mode, clickon the plus sign "+" next to Type Libraries in the left window pane, then double-click on the Metrowerks CodeWarrior IDE entry. A window similar to Figure 3.2 appears. Then use the View menu of the ITypeLib Viewer window to choose Group by type kind. Then click on the plus sign "+" next to CoClasses, then the + next to coclass CodeWarriorApp, then the + next to Methods. Click on OpenProject and your window should now look something like that shown in Figure 3.3.
filePath
- the path to the project to be opened.
fMakeVisible
- whether to make the project visible or not.
convertOption
- whether to allow the project to be converted or not (taking a value from the ECodeWarriorConvertOption
enumeration).
revertOption
- the value from the enumeration named ECodeWarriorRevertPanelOption
.
The scripts in this section are:
wscript select~1.vbs "C:\testproejcts\test1.mcp"
option explicit
'*******Variable declaration
dim codewarrior
dim project
dim projectname
dim targetIntf
dim count
dim projectCollection
dim targetcollection
dim result
dim showinputbox
dim objArgs
'****** Script ********
Set objArgs = Wscript.Arguments
projectname = "c:\testprojects\test1.mcp"
if objArgs.Count > 1 then
MsgBox "This Script expects only one argument, rest of the arguments will be ignored!!"
showinputbox = false
projectname = CStr(objArgs(0))
end if
if objArgs.Count = 0 then
showinputbox = true
else
showinputbox = false
projectname = CStr(objArgs(0))
end if
if showinputbox = true then
result = InputBox("Enter the absolute path for the project to be opened","Input", projectname, 100, 100)
If result = "" Then
projectname = "c:\testprojects\test1.mcp"
else
projectname = cstr(result)
end if
end if
'Create automation app object
set codewarrior = CreateObject("CodeWarrior.CodeWarriorApp")
MsgBox "App Created"
project = Null
'open project
set project = codewarrior.OpenProject(projectname, true, 2, 0 )
if TypeName( project ) <> "Null" then
set targetcollection = project.Targets
count = targetcollection.Count
IF ( count > 0 ) then
set targetIntf = targetcollection.Item( 0 )
targetIntf.RemoveObjectCode( true )
END IF
else
MsgBox CStr( projectname & " does not exist" )
end if
wscript select~1.vbs "C:\testprojects\test1.mcp"
option explicit
'*******Variable declaration
dim codewarrior
dim project
dim projectname
dim targetIntf
dim count
dim projectCollection
dim targetcollection
dim result
dim showinputbox
dim objArgs
dim buildErrors
'****** Script ********
Set objArgs = Wscript.Arguments
projectname = "c:\temp\none\none.mcp"
if objArgs.Count > 1 then
MsgBox "This Script expects only one argument, rest of the arguments will be ignored!!"
showinputbox = false
projectname = CStr(objArgs(0))
end if
if objArgs.Count = 0 then
showinputbox = true
else
showinputbox = false
projectname = CStr(objArgs(0))
end if
if showinputbox = true then
result = InputBox("Enter the absolute path for the project to be opened","Input", projectname, 100, 100)
If result = "" Then
projectname = "c:\testprojects\test1.mcp"
else
projectname = cstr(result)
end if
end if
'Create automation app object
set codewarrior = CreateObject("CodeWarrior.CodeWarriorApp")
MsgBox "App Created"
project = Null
'open project
set project = codewarrior.OpenProject(projectname, true, 2, 0 )
if TypeName( project ) <> "Null" then
project.BuildAndWaitToComplete
else
MsgBox CStr( projectname & " does not exist" )
end if
project.close